package gates;
import java.awt.Graphics;

import master.*;

/**
 * 
 * @author Matthew & Oliver
 *
 *First step in a Grover iterate
 *
 *search through list for desired state, and flip it through Pi radians if it is there.
 *
 *
 */


public class Oracle extends QuantumGate {

	private int search;
	
	public Oracle(int search){
		this.search = search;
	}
	
	
	public void actOnReg(QuantumRegister register){
		
		if (search > register.getDimension() || search < 0){
			throw new IllegalArgumentException("This is not a possible state of the register");
		}
		
		for(int i = 0; i < register.getDimension(); i++){
			
			
			
			if(i == search){
				ComplexNumber temp = register.getCoefficient(i).multByNo(-1f);
				register.setCoefficient(temp, i);
				break;
			}
			
			
		}
		
	}


	


	@Override
	public int[] getActingBits() {
		int[] a = new int[1];
		a[0] = -1;
		return a;
	}
	
	
}
